package cn.edu.scau.cmi.util;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

//自动生成“带有模板内容”的jet模板文件
public class GenarateJetFileUtil {

	public static void main(String[] args) throws IOException {
		generateJetAccordDirectory(new File("css"));

	}

	private static void generateJetAccordDirectory(File srcDirectory) throws IOException {
		File src=new File("templates\\content\\ssh\\"+srcDirectory.getName());
		File target=new File("templates\\test\\"+srcDirectory.getName()+"Process.jet");
		generateJet(src,target);
	}

	@SuppressWarnings("deprecation")
	private static void generateJet(File src, File target) throws IOException {
//		File target=new File("cssProcess.jet");
		String[] srcFileList = src.list();
		
		FileUtils.writeStringToFile(target, "<%@taglib prefix=\"ws\" id=\"org.eclipse.jet.workspaceTags\" %>"+"\n",true);
		for(String srcFile:srcFileList) {
			System.out.println(srcFile);
			
//			<ws:copyFile src="templates/content/css/bootstrap.css" target="{$projectName}/WebRoot/css/bootstrap.css"/>
			
			FileUtils.writeStringToFile(target, "<ws:copyFile src=\"templates/content/css/"+srcFile+"\""+" target=\"{$projectName}/WebRoot/css/"+srcFile+"\"/>"+"\n",true);
		}
		
	}
	
	

}
